package com.whale.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabWidget;

import com.whale.NearbyActivity;
import com.whale.PostStreamActivity;
import com.whale.R;
import com.whale.ReplyActivity;
import com.whale.TrendsActivity;

public class WhaleTabActivity extends TabActivity {

    private TabHost   mTabHost;
    private TabWidget mTabWidget;
    private Button    titleLeftBt;
    private Button    titleRightBt;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_tab_activity);

        titleLeftBt = (Button) findViewById(R.id.title_left_button);
        titleRightBt = (Button) findViewById(R.id.title_right_button);
        
        mTabHost = this.getTabHost();
        Resources res = getResources();
        Intent tab1 = new Intent(this, TrendsActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec(res.getString(R.string.tab1)).setIndicator(res.getString(R.string.tab1)).setContent(tab1));

        Intent tab2 = new Intent(this, NearbyActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec(res.getString(R.string.tab2)).setIndicator(res.getString(R.string.tab2)).setContent(tab2));

        Intent tab3 = new Intent(this, ReplyActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec(res.getString(R.string.tab3)).setIndicator(res.getString(R.string.tab3)).setContent(tab3));

        Intent tab4 = new Intent(this, TrendsActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec(res.getString(R.string.tab4)).setIndicator(res.getString(R.string.tab4)).setContent(tab4));

        RadioGroup radioGroup = (RadioGroup) findViewById(R.id.bottom_states_bt);

        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.tab1:
                        mTabHost.setCurrentTab(0);
                        break;
                    case R.id.tab2:
                        mTabHost.setCurrentTab(1);
                        break;
                    case R.id.tab3:
                        mTabHost.setCurrentTab(2);
                        break;
                    case R.id.tab4:
                        mTabHost.setCurrentTab(3);
                        break;

                }
            }
        });

        titleRightBt.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent(WhaleTabActivity.this, PostStreamActivity.class);
                intent.putExtra("tip", "分享美食");
                startActivity(intent);
            }
        });
        

    }

    @Override
    protected void onStart() {
        super.onStart();

    }

}
